import request from "@/utils/request.js";
/**
 * 单独设置商家返点列表
 * @param params
 */
export const pageList = query => {
  return request({
    url: "/purchase/factoryToBusiness/pageList",
    method: "get",
    params: query
  });
};

/**
 * 获取可设置工厂和商户一对一返佣比例的工厂数据（当前工厂返佣状态为待开启，已开启，续约中）
 * @param params
 */
export const listFactory = query => {
  return request({
    url: "/purchase/factoryToBusiness/listFactory",
    method: "get",
    params: query
  });
};

/**
 * 获取所有租户表中的商户数据
 * @param params
 */
export const listBusiness = query => {
  return request({
    url: "/purchase/factoryToBusiness/listBusiness",
    method: "get",
    params: query
  });
};

/**
 * 根据工厂id获取工厂返佣状态为待开启，已开启，续约中的返佣比例（新增时查询）
 * @param params
 */
export const getFactoryRatioByFactoryId = query => {
  return request({
    url: "/purchase/factoryToBusiness/getFactoryRatioByFactoryId",
    method: "get",
    params: query
  });
};

/**
 * 新增单独设置商家返点
 * @param params
 */
export const insertBusinessRatio = data => {
  return request({
    url: "/purchase/factoryToBusiness/insertBusinessRatio",
    method: "post",
    data
  });
};

/**
 * 新增商家等级
 * @param params
 */
export const addLevel = data => {
  return request({
    url: "/purchase/business/level/add",
    method: "post",
    data
  });
};

/**
 * 商家等级选择列表查询
 * @param params
 */
export const settingPage = query => {
  return request({
    url: "/purchase/factoryToBusinessLevel/setting/page",
    method: "get",
    params: query
  });
};

/**
 * 取消单独设置商家返点
 * @param params
 */
export const cancelBusinessRatio = query => {
  return request({
    url: "/purchase/factoryToBusiness/cancelBusinessRatio/" + query.factoryBusinessCommissionId,
    method: "DELETE"
  });
};

/**
 * 续约调整列表
 * @param params
 */
export const renewPageList = query => {
  return request({
    url: "/purchase/factoryToBusiness/renew/pageList",
    method: "get",
    params: query
  });
};

/**
 * 获取单独设置商家返点详情
 * @param params
 */
export const getDetail = query => {
  return request({
    url: "/purchase/factoryToBusiness/getDetail/" + query.factoryBusinessCommissionId,
    method: "get"
  });
};

/**
 * 编辑单独设置商家返点
 * @param params
 */
export const updateBusinessRatio = data => {
  return request({
    url: "/purchase/factoryToBusiness/updateBusinessRatio",
    method: "post",
    data
  });
};

/**
 * 查询已设置调整续约详情
 * @param params
 */
export const getRenewDetail = query => {
  return request({
    url: "/purchase/factoryToBusiness/renew/getRenewDetail/" + query.factoryBusinessCommissionId,
    method: "get"
  });
};

/**
 * 查询未设置调整续约详情
 * @param params
 */
export const unSetRenewDetail = query => {
  return request({
    url: "/purchase/factoryToBusiness/renew/unSetRenewDetail/" + query.factoryBusinessCommissionId,
    method: "get"
  });
};

/**
 * 新增续约单独设置商家返点
 * @param params
 */
export const insertRenewRatio = data => {
  return request({
    url: "/purchase/factoryToBusiness/renew/insertRenewRatio",
    method: "post",
    data
  });
};

/**
 * 商家单独设置统计：全部，续约设置
 * @param params
 */
export const factoryBusinessCount = query => {
  return request({
    url: "/purchase/factoryToBusiness/factoryBusinessCount",
    method: "get",
    params: query
  });
};

/**
 * 商家等级营销返佣详情
 * @param params
 */
export const salesDetail = businessLevelId => {
  return request({
    url: `/purchase/business/level/sales/detail/${businessLevelId}`,
    method: "get"
  });
};

/**
 * 新增/修改商家等级营销返佣
 * @param params
 */
export const addOrUpdateSales = data => {
  return request({
    url: "/purchase/business/level/sales/addOrUpdateSales",
    method: "post",
    data
  });
};

/**
 * 商家单独设置营销返佣列表
 * @param params
 */
export const salesPageList = query => {
  return request({
    url: `/purchase/business/sales/pageList`,
    method: "get",
    params: query
  });
};

/**
 * 获取未设置营销返佣的商户数据
 * @param params
 */
export const listUnsetSalesBusiness = query => {
  return request({
    url: `/purchase/business/sales/listUnsetSalesBusiness`,
    method: "get",
    params: query
  });
};

/**
 * 新增/修改商家单独设置营销返佣
 * @param params
 */
export const salesAdd = data => {
  return request({
    url: "/purchase/business/sales/add",
    method: "post",
    data
  });
};

/**
 * 商家等级营销返佣详情
 * @param params
 */
export const onlySalesDetail = businessId => {
  return request({
    url: `/purchase/business/sales/detail/${businessId}`,
    method: "get"
  });
};

/**
 * 取消单独设置商家返点
 * @param params
 */
export const salesDelete = businessId => {
  return request({
    url: `/purchase/business/sales/delete/${businessId}`,
    method: "DELETE"
  });
};
